package com.myh.cc.network.request

import com.myh.cc.base.BaseApplication
import com.myh.cc.base.CityInfo
import com.myh.cc.coom.main.bean.PlayKey
import com.myh.cc.coom.ranking.bean.RankingBean
import com.myh.cc.coom.ranking.bean.RankingDetailsBean
import com.myh.cc.coom.recommend.bean.BannerBean
import com.myh.cc.coom.recommend.bean.RecommendBean
import com.myh.cc.coom.recommend.bean.RecommendDetaislBean
import com.myh.cc.coom.search.bean.HotBean
import com.myh.cc.coom.search.bean.SearchBean
import com.myh.cc.coom.singer.bean.SingerBean
import com.myh.cc.coom.singer.bean.SingerDetailsBean
import com.myh.cc.network.RetrofitManager
import com.myh.cc.util.ConstantUtil
import com.myh.cc.util.NetUtil
import io.reactivex.Observable

/**
 * 类描述    ：
 * 创建人    ：  mayahao.
 * 创建时间   ：  2018/1/3.
 * 修改人    ：
 * 修改时间   ：
 * 修改备注   ：
 */
class HttpRequestImpl: IHttpRequest {

    companion object {
            val httpRequest:HttpRequestImpl = HttpRequestImpl()
    }

    /**
     * 根据网络状况获取缓存的策略
     */
    private fun getCacheControl(): String {
        return if (NetUtil.isConnected(BaseApplication.context)) ConstantUtil.SCACHE_CONTROL_AGE else ConstantUtil.SCACHE_CONTROL_CACHE
    }


    override fun getWeather(header: String,map: Map<String, String>): Observable<CityInfo> {

        return RetrofitManager.appService.getWeather(header,map)

    }

    override fun getRecommend(header: String, map: Map<String, String>): Observable<RecommendBean> {
        return RetrofitManager.appService.getRecommend(header,map)
    }


    override fun getRanking(header: String, map: Map<String, String>): Observable<RankingBean> {
        return RetrofitManager.appService.getRanking(header,map)
    }

    override fun getSinger(header: String, map: Map<String, String>): Observable<SingerBean> {
        return RetrofitManager.appService.getSinger(header,map)
    }

    override fun getHotSearch(header: String, map: Map<String, String>): Observable<HotBean> {
        return RetrofitManager.appService.getHotSearch(header,map)
    }

    override fun getSearch(header: String, map: Map<String, String>): Observable<SearchBean> {
        return RetrofitManager.appService.getSearch(header,map)
    }

    override fun getBanner(header: String, map: Map<String, String>): Observable<BannerBean> {
        return RetrofitManager.appService.getBanner(header,map)
    }

    override fun getSingerDetails(header: String, map: Map<String, String>): Observable<SingerDetailsBean> {
        return RetrofitManager.appService.getSingerDetails(header,map)
    }

    override fun getRankingDetails(header: String, map: Map<String, String>): Observable<RankingDetailsBean> {
        return RetrofitManager.appService.getRankingDetails(header,map)
    }

    override fun getRecommendDetails(header: String, map: Map<String, String>): Observable<RecommendDetaislBean> {
       return RetrofitManager.appService.getRecommendDetails(header,map)
    }

    override fun getPlayKey(header: String, map: Map<String, String>): Observable<PlayKey> {
        return RetrofitManager.appService.getPlayKey(header,map)
    }
}